﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.ETL.Domain.Services
{
    public class ListService
    {
        public ListResult<Entities.ETaskCategory> ListRootTaskCategory()
        {
            using (EtlDbContext dbContext = new EtlDbContext())
            {
                List<Entities.ETaskCategory> list = dbContext.Set<Entities.ETaskCategory>().Where(p => p.ParentId == null)
                    .OrderBy(p => p.Code).ToList();
                return new ListResult<Entities.ETaskCategory>(true, 0, "", list);
            }
        }

        public ListResult<Entities.ETaskCategory> ListSubTaskCategory(Guid parentId)
        {
            using (EtlDbContext dbContext = new EtlDbContext())
            {
                List<Entities.ETaskCategory> list = dbContext.Set<Entities.ETaskCategory>().Where(p => p.ParentId == parentId)
                    .OrderBy(p => p.Code).ToList();
                return new ListResult<Entities.ETaskCategory>(true, 0, "", list);
            }
        }
    }
}
